# $Id$
# Maintainer : Felix Yan <felixonmars@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgbase=pyopenssl
pkgname=('python-pyopenssl' 'python2-pyopenssl')
pkgver=18.0.0
pkgrel=2
arch=('any')
pkgdesc="Python3 wrapper module around the OpenSSL library"
url='https://github.com/pyca/pyopenssl'
license=('Apache')
makedepends=('openssl' 'python-setuptools' 'python2-setuptools' 'python-cryptography'
             'python2-cryptography' 'python-six' 'python2-six')
checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'python-pretend' 'python2-pretend'
              'python-flaky' 'python2-flaky')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/pyca/pyopenssl/archive/${pkgver}.tar.gz)
sha512sums=('cd744199eff889e22b178adc3bec75f5e1b2c719d5fe1ea48a0003f1fb23c5ad7cd8ec0b2cdb92948947afb6cba4181bda39ab2eb04dc6f3c019fc2e1822ed00')

prepare() {
  cp -a pyopenssl-$pkgver{,-py2}
  export LC_CTYPE=en_US.UTF-8
}

build() {
  cd "$srcdir"/pyopenssl-$pkgver
  python setup.py build

  cd "$srcdir"/pyopenssl-$pkgver-py2
  python2 setup.py build
}

check() {
  (
    cd "$srcdir"/pyopenssl-$pkgver
    python setup.py pytest

    cd "$srcdir"/pyopenssl-$pkgver-py2
    python2 setup.py pytest
  ) || warning "Tests failed due to missing SSLv3_METHOD"
}

package_python-pyopenssl() {
  depends=('openssl' 'python' 'python-six' 'python-cryptography')
  replaces=('pyopenssl')
  provides=('pyopenssl')
  conflicts=('pyopenssl')

  cd pyopenssl-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}

package_python2-pyopenssl() {
  depends=('openssl' 'python2' 'python2-six' 'python2-cryptography')

  cd pyopenssl-$pkgver-py2
  python2 setup.py install --root="$pkgdir" --optimize=1 --skip-build
}

# vim: ts=2 sw=2 et:
